package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.model.User;
import com.zr.service.Sbqdservice;
import com.zr.serviceImpl.SbqdserviceImpl;

public class SbqdController extends HttpServlet{
     Sbqdservice s=new SbqdserviceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		 SimpleDateFormat sdf =   new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss " ); 
		 SimpleDateFormat sd =   new SimpleDateFormat( "yyyy-MM-dd" ); 
		 String date=sdf.format(new Date());
		 String data=sd.format(new Date());
		 HttpSession session=req.getSession();
		  User u=(User) session.getAttribute("user");
		   PrintWriter pw=resp.getWriter();
		   String string= s.findsj(u.getUsernum());
		   if(data.equals(string)){
           	pw.write("0");
           }else{
           	 boolean b= s.findsbqd(u.getUsernum(), date);
           	   if(b){
     	        	 pw.write("true");
     	         }else{
     	        	 pw.write("false");
     	         }
           }
 
		     
		   pw.flush();
		   pw.close();
	}
   
}
